package com.demo.my.Controller.detail;


import com.demo.my.Entity.LeaveInfoDTO;
import com.demo.my.Service.LeaveService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 请假批准的方法
 */
@WebServlet("/leavePageAuthorizeServlet")
public class LeavePageOfAuthorizeServlet extends HttpServlet {
    private LeaveService leaveService=new LeaveService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        try {
            List<LeaveInfoDTO> list = leaveService.getLeaveList();
            List<LeaveInfoDTO> yesList = list.stream().filter(e -> {
                return e.getStatus().trim().equals("已批准");
            }).collect(Collectors.toList());
            req.setAttribute("list",yesList);
            req.getRequestDispatcher("/jsp/admin/leave_yeslist.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
